package com.goldfish666.remote_control.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ControlTypeEnum {

    /**
     * state
     */
    state(0,"state"),

    /**
     * command
     */
    command(1,"command");


    private int value;

    private String desc;

    ControlTypeEnum(int option, String desc) {
        this.value = option;
        this.desc = desc;
    }

    @JsonCreator
    public static ControlTypeEnum fromValue(@JsonProperty("value") final int option) {
        for (ControlTypeEnum e : ControlTypeEnum.values()) {
            if (e.value == option) {
                return e;
            }
        }
        return null;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
}
